package com.example.demo.controller;

import com.example.demo.config.AuthAccess;
import com.example.demo.pojo.ResultResp;
import com.example.demo.service.impl.RedisAndMongoTemplateServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
//import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author CHAS
 * 2024/7/27 9:28
 **/
@Slf4j
//@RefreshScope
@RestController
@RequestMapping("/web")
@Api(tags = "web后台")
public class RedisAndMongoController {
    @Resource
    private RedisAndMongoTemplateServiceImpl redisAndMongoTemplateService;
    @PostMapping("/redisSetHash")
    @ApiOperation(value = "redisSetHash操作")
    @AuthAccess(message = "这是自定义注解返回的信息！")
    public ResultResp redisSetHash() {
        log.info("redisSetHash");
        return redisAndMongoTemplateService.redisSetHash();
    }
    @PostMapping("/deleteRedisHash")
    @ApiOperation(value = "redisDeleteHash操作")
    public ResultResp deleteRedisHash() {
        log.info("deleteRedisHash");
        return redisAndMongoTemplateService.deleteRedisHash();
    }
    @PostMapping("/getRedisHash")
    @ApiOperation(value = "getRedisHash")
    public ResultResp getRedisHash() {
        log.info("getRedisHash");
        return redisAndMongoTemplateService.getRedisHash();
    }
    @PostMapping("/mongoInsert")
    @ApiOperation(value = "mongoInsert操作")
    public ResultResp mongoInsert() {
        log.info("mongoInsert");
        return redisAndMongoTemplateService.mongoInsert();
    }
}
